<?php
include("../util/session.php");
	require_once ("../config.inc.php");
	require_once ("../include/mysql.inc.php");
	require_once ("../include/articleType.inc.php");
	require_once ("../include/article.inc.php");
	$articleTypeDao = new ArticleType();
	$typeRows = $articleTypeDao->query();//得到所有的文章类型列表
	
	$articleDao = new Article();
	$typeId = mysql_escape_string($_GET["typeId"]);
	$pageIndex = mysql_escape_string($_GET["pageIndex"]);
	$articleRows = $articleDao->query($typeId, $pageIndex, ARTICLE_PAGE_SIZE);//得到当前页的文章列表
	
	$totalPage = count($articleRows);
?>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title></title>
	</head>
	<body>
		<?php
			require './inc_header.php';
		?>
		<a href="articleAdd.php">添加</a>
		<div style="width: 1000px;">
		<div style="float: left; margin-right: 2px;">
		<table width="90" border="1">
			<tr><td>文章类型</td></tr>
			<tr><td><a href="articleList.php">全部文章</td></tr>
			<?php foreach ($typeRows as $typeValue) {?>
			<tr><td><a href="articleList.php?typeId=<?php echo $typeValue[id] ?>&pageIndex=<?php echo $pageIndex ?>"><?php echo $typeValue[name] ?></a></td></tr>
			<?php }?>
		</table>
		</div>
		<div>
		<table width="900" border="1">
			<tr align="center">
				<td width="5%">编号</td>
				<td width="55%">标题</td>
				<td width="10%">作者</td>
				<td width="15%">时间</td>
				<td width="15%">操作</td>
			</tr>
			<?php foreach ($articleRows as $articleValue) {?>
			<tr>
				<td><?php echo $articleValue[id] ?></td>
				<td><a href="article.php?id=<?php echo $articleValue[id] ?>"><?php echo $articleValue[title] ?></a></td>
				<td><?php echo $articleValue[adminId] ?></td>
				<td><?php echo $articleValue[time] ?></td>
				<td>
					<?php if ($articleValue[top] == 1) {?>
					<a href="../action/article/topArticle.php?id=<?php echo $articleValue[id] ?>&v=0">不置顶</a>|
					<?php } else {?>
					<a href="../action/article/topArticle.php?id=<?php echo $articleValue[id] ?>&v=1">置顶</a>|
					<?php }?>
					<a href="articleUpdate.php?id=<?php echo $articleValue[id] ?>">修改</a>|
					<a href="../action/article/delArticle.php?id=<?php echo $articleValue[id] ?>">删除</a>
				</td>
			</tr>
			<?php }?>
		</table>
		</div>
		</div>
	</body>
</html>